/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 根元素变量定义 */
:root {
    --primary-color: #d4a574;
    --secondary-color: #8b4513;
    --accent-color: #cd853f;
    --text-primary: #2c2c2c;
    --text-secondary: #666;
    --bg-primary: #faf8f5;
    --bg-secondary: #fff;
    --border-color: #e8e4df;
    --shadow-light: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 16px rgba(0,0,0,0.15);
    --border-radius: 12px;
    --font-family: 'Noto Serif SC', serif;
}

/* 基础样式 */
body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-primary) 0%, #f5f1eb 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 16px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    text-align: center;
    padding: 40px 0;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color), var(--primary-color));
}

.title {
    font-size: clamp(2rem, 5vw, 3rem);
    color: var(--secondary-color);
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 1px;
}

/* 主内容区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 筛选区域样式 */
.filter-section {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.filter-select, .surname-input {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.filter-select:focus, .surname-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.2);
}

.generate-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    box-shadow: var(--shadow-light);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.generate-btn:active {
    transform: translateY(0);
}

.favorites-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    box-shadow: var(--shadow-light);
    position: relative;
}

.favorites-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.favorites-btn:active {
    transform: translateY(0);
}

.favorites-count {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}

.config-btn {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    box-shadow: var(--shadow-light);
}

.config-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.config-btn:active {
    transform: translateY(0);
}

/* 结果区域样式 */
.results-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow-light);
    min-height: 400px;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.loading-animation {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.results-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.name-card {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.name-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 12px;
}

.name-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--secondary-color);
}

.name-pinyin {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.name-source {
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: 500;
    margin-bottom: 12px;
}

.name-preview {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.favorite-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.3s ease;
    line-height: 1;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorite-btn:hover {
    background: rgba(212, 165, 116, 0.1);
    transform: scale(1.1);
}

.favorite-card {
    border-left: 4px solid #e74c3c;
}

.favorite-time {
    font-size: 0.8rem;
    color: #999;
    margin-top: 8px;
    text-align: right;
}

/* 模态弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.modal-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--secondary-color);
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--secondary-color);
}

.modal-body {
    padding: 0 24px 24px;
}

.name-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item label {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 1rem;
}

.original-text, .meaning-text {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* 页脚样式 */
.footer {
    text-align: center;
    padding: 30px 0;
    margin-top: 40px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 工具类 */
.hidden {
    display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .filter-section {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    
    .results-container {
        grid-template-columns: 1fr;
    }
    
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    .header {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .modal-header {
        padding: 16px 16px 0;
        margin-bottom: 16px;
    }
    
    .modal-body {
        padding: 0 16px 16px;
    }
    
    .modal-name {
        font-size: 1.5rem;
    }
}